package com.fare.taluo.core.domain.crawl.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.dayatang.hibernate.EntityRepositoryHibernate;
import com.fare.taluo.core.domain.crawl.FligthStatusInfoEntity;
import com.fare.taluo.core.domain.crawl.FligthStatusInfoEntityRepository;
@Repository
public class FligthStatusInfoEntityRepositoryImpl extends EntityRepositoryHibernate implements FligthStatusInfoEntityRepository{

	@Override
	public List<FligthStatusInfoEntity> findAll() {
		StringBuffer sbf=new StringBuffer("from FligthStatusInfoEntity a where 1=1 ");
		List<Object> params = new ArrayList<Object>();
		sbf.append(" order by a.createTime desc");//此排序不可删除，否则直接影响持久化操作
		List<FligthStatusInfoEntity> list = new ArrayList<FligthStatusInfoEntity>();
		list=this.find(sbf.toString(),params.toArray(),FligthStatusInfoEntity.class);
		return list;
	}

	@Override
	public List<FligthStatusInfoEntity> findByCondition(String grabDateStr) {
		StringBuffer sbf=new StringBuffer("from FligthStatusInfoEntity a where 1=1 ");
		List<Object> params = new ArrayList<Object>();
		if( grabDateStr !=null ){
			sbf.append(" and a.grabDate= ?");
			params.add(grabDateStr);
		}
		sbf.append(" order by a.createTime desc");
		
		List<FligthStatusInfoEntity> list = new ArrayList<FligthStatusInfoEntity>();
		list=this.find(sbf.toString(),params.toArray(),FligthStatusInfoEntity.class);
		return list;
	}

	@Override
	public void updateVo(FligthStatusInfoEntity entity) {
		Session session = super.getSession();
		session.merge(entity);
		
	}

}
